home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / DiscreteUniform.h,v < prev    next >
Text File  |  1989-07-18  |  2KB  |  118 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.34.15;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.1;
  13.  
  14. 3.1
  15. date     88.12.20.13.49.40;  author grunwald;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 3.2
  25. log
  26. @Start using Gnu library heaps for schedulers
  27. @
  28. text
  29. @// This may look like C code, but it is really -*- C++ -*-
  30. /* 
  31. Copyright (C) 1988 Free Software Foundation
  32.     written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  33.  
  34. This file is part of GNU CC.
  35.  
  36. GNU CC is distributed in the hope that it will be useful,
  37. but WITHOUT ANY WARRANTY.  No author or distributor
  38. accepts responsibility to anyone for the consequences of using it
  39. or for whether it serves any particular purpose or works at all,
  40. unless he says so in writing.  Refer to the GNU CC General Public
  41. License for full details.
  42.  
  43. Everyone is granted permission to copy, modify and redistribute
  44. GNU CC, but only under the conditions described in the
  45. GNU CC General Public License.   A copy of this license is
  46. supposed to have been given to you along with GNU CC so you
  47. can know your rights and responsibilities.  It should be in a
  48. file named COPYING.  Among other things, the copyright notice
  49. and this notice must be preserved on all copies.  
  50. */
  51. #ifndef _DiscreteUniform_h
  52. #define _DiscreteUniform_h 1
  53.  
  54. #include <Random.h>
  55.  
  56. //
  57. //    The interval [lo..hi)
  58. // 
  59.  
  60. class DiscreteUniform: public Random {
  61.     long pLow;
  62.     long pHigh;
  63.     double delta;
  64. public:
  65.     DiscreteUniform(long low, long high, RNG *gen);
  66.  
  67.     long low();
  68.     long low(long x);
  69.     long high();
  70.     long high(long x);
  71.  
  72.     virtual double operator()();
  73. };
  74.  
  75. //#ifdef __OPTIMIZE__
  76.  
  77. #include <stream.h>
  78.  
  79. inline DiscreteUniform::DiscreteUniform(long low, long high, RNG *gen) : (gen)
  80. {
  81.     pLow = (low < high) ? low : high;
  82.     pHigh = (low < high) ? high : low;
  83.     delta = (pHigh - pLow) + 1;
  84. }
  85.  
  86. inline long DiscreteUniform::low() { return pLow; }
  87.  
  88. inline long DiscreteUniform::low(long x) {
  89.   long tmp = pLow;
  90.   pLow = x;
  91.   delta = (pHigh - pLow) + 1;
  92.   return tmp;
  93. }
  94.  
  95. inline long DiscreteUniform::high() { return pHigh; }
  96.  
  97. inline long DiscreteUniform::high(long x) {
  98.   long tmp = pHigh;
  99.   pHigh = x;
  100.   delta = (pHigh - pLow) + 1;
  101.   return tmp;
  102. }
  103.  
  104. //#endif
  105. #endif
  106. @
  107.  
  108.  
  109. 3.1
  110. log
  111. @Steay version
  112. @
  113. text
  114. @a52 2
  115.     cerr << "I am a discrete uniform and I like it\n";
  116.     cerr.flush();
  117. @
  118.